import numpy as np
# 1 向量被广播
arr1 = np.array([-100,0,100])
print(arr1) # [-100    0  100]
# 矩阵
arr2 = np.random.random( (10,3) )
print(arr2) # 输出10行3列  0-1分布的矩阵
print(arr1 * arr2)
"""
[[-66.96547968   0.          68.37082302]
 [ -1.55505979   0.          77.05474272]
 [ -1.63359141   0.          45.32001258]
 [-60.86424391   0.          84.18419456]
 [-88.41135459   0.          49.60201045]
 [-85.01580732   0.          41.53617786]
 [-41.6306934    0.          59.2315329 ]
 [-78.24758905   0.          75.78799517]
 [-26.57626746   0.           2.50067566]
 [-61.96546629   0.          14.3932051 ]]
"""

# 2 行矩阵被广播
arr1 = np.array([[-100,0,100]])
print(arr1) # [[-100    0  100]]
# 矩阵
arr2 = np.random.random( (10,3) )
print(arr2) # 输出10行3列  0-1分布的矩阵
print(arr1 * arr2)

# 3 列矩阵被广播
arr1 = np.arange(3).reshape(3,1)
print(arr1)
"""
[[0]
 [1]
 [2]]
"""
# 矩阵
arr2 = np.ones( (3,5) )
print(arr2)
"""
[[1. 1. 1. 1. 1.]
 [1. 1. 1. 1. 1.]
 [1. 1. 1. 1. 1.]]
"""
print(arr1 * arr2)
"""
[[0. 0. 0. 0. 0.]
 [1. 1. 1. 1. 1.]
 [2. 2. 2. 2. 2.]]
"""


# 向量
arr1 = np.arange(3)
# arr1 = np.arange(3).reshape(1,3)
print(arr1) # [0 1 2]
# 列矩阵
arr2 = np.arange(3).reshape(3,1)
print(arr2)
"""
[[0]
 [1]
 [2]]
"""
print(arr1 * arr2)
"""
[[0 0 0]
 [0 1 2]
 [0 2 4]]
"""